<?php

namespace App\Admin\Actions\Post;

use Encore\Admin\Actions\BatchAction;
use Illuminate\Database\Eloquent\Collection;
use App\User;

class BatchPrize extends BatchAction
{
    public $name = '抽取中奖者';

    public function handle(Collection $collection)
    {
        foreach ($collection as $model) {
            DB::table('user_prize')->insert([
                'user_id'=>$model['id'],
                'price'=>50,
                'get_date'=>date('Y-m-d',time()+3600*24*7),
            ]);
        }

        die;

        return $this->response()->success('抽取成功')->refresh();
    }

}